{extend name="../../base/view/common/base" /}
<!-- 主体 -->
{block name="body"}
<div class="p-page">
    <table class="layui-hide" id="test" lay-filter="test"></table>
</div>
<script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
	<h3>{$detail.title} 学习记录列表</h3>
  </div>
</script>
{/block}
<!-- /主体 -->

<!-- 脚本 -->
{block name="script"}
	<script>
	const moduleInit = ['tool','tablePlus'];
	const course_id = {$detail.id};
	function gouguInit() {
		var table = layui.tablePlus, tool = layui.tool, form = layui.form;
		layui.pageTable = table.render({
			elem: '#test'
			,toolbar: '#toolbarDemo'
			,defaultToolbar:['filter', {title:'导出EXCEL',layEvent: 'LAYTABLE_EXCEL',icon: 'layui-icon-export'}]
			,title:'学习记录列表'
			,height: 'full-14'
			,url: "/course/course/record"
			,where:{id:course_id}
			,page: true
			,cellMinWidth: 80
			,cols: [[
				{field:'user_id',width:80, title: '学员ID', align:'center'}
				,{field:'user',width:100,align:'center',title: '学员姓名'}
				,{field:'create_time',width:160,align:'center', title: '开始学习时间'}
				,{field:'progress',width:100,align:'center',title: '学习进度',templet: function(d){
					if(d.progress==0){
						return d.progress;
					}
					else{
						return d.progress+'%';
					}
				}}
				,{field:'duration',align:'center',width:150,title: '学习耗时'}
				,{field:'department',title: '学员所在部门'}
				,{field:'position',width:150,align:'center',title: '学员职称'}
				,{width:80,fixed:'right', title: '操作', align:'center',templet: function(d){
					return '<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">移除</a>';
				}}
			]]
		});
		
		table.on('tool(test)',function (obj) {
			if(obj.event === 'delete'){		
				let callback = function (e) {
					layer.msg(e.msg);
					if(e.code==0){
						layui.pageTable.reload();
					}
				}
				layer.confirm('确定要移除该学员的学习记录吗?', {icon: 3, title:'提示'}, function(index){
					tool.post("/course/course/record_del", {id:obj.data.id}, callback);
					layer.close(index);
				});
			}
		})
	}
	</script>
{/block}
<!-- /脚本 -->